import 'package:flutter/material.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:oramemo/common/langs/text_key.dart';
import 'package:oramemo/widget/gradient_app_head.dart';
import 'package:oramemo/widget/gradient_background.dart';
import 'package:oramemo/widgets/filter_dropdown.dart';
import '../widgets/transcription_item.dart';

class TranscriptionListPage extends StatelessWidget {
  TranscriptionListPage({super.key});

  final List<FilterOption> _filterDate = [
    FilterOption(id: '1', name: TextKey.dateLastWeek.tr),
    FilterOption(id: '2', name: TextKey.dateLastMonth.tr),
    FilterOption(id: '3', name: TextKey.dateLastYear.tr),
    FilterOption(id: '4', name: TextKey.allDates.tr),
  ];

  final List<FilterOption> _filterState = [
    FilterOption(id: '1', name: TextKey.statusSuccess.tr),
    FilterOption(id: '2', name: TextKey.statusFailed.tr),
    FilterOption(id: '3', name: TextKey.statusInProgress.tr),
    FilterOption(id: '4', name: TextKey.allStatus.tr),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          GradientAppHead(
            title: TextKey.transcriptionRecordTitle.tr,
          ),
          Expanded(
            child: GradientBackground(
              child: Column(
                children: [
                  Padding(
                    padding: const EdgeInsets.all(16.0),
                    child: Row(
                      children: [
                        Expanded(
                          child: _buildDropdownButton(
                              TextKey.allDates.tr, _filterDate,
                              (selectedOptions) {
                            if (selectedOptions.isNotEmpty) {
                              // 选中的日期区间;
                            }
                          }),
                        ),
                        const SizedBox(width: 16),
                        Expanded(
                          child: _buildDropdownButton(
                              TextKey.allStatus.tr, _filterState,
                              (selectedOptions) {
                            if (selectedOptions.isNotEmpty) {
                              //选中的状态
                            }
                          }),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: ListView(
                      padding: const EdgeInsets.all(16),
                      children: const [
                        TranscriptionItem(
                          title: '2024年Q1季度营销会议记录.mp3',
                          date: '2024-01-15 14:30',
                          duration: '25分钟',
                          status: TranscriptionStatus.completed,
                        ),
                        TranscriptionItem(
                          title: '2024年Q1季度营销会议记录.mp3',
                          date: '2024-01-15 14:30',
                          duration: '25分钟',
                          status: TranscriptionStatus.failed,
                        ),
                        TranscriptionItem(
                          title: '2024年Q1季度营销会议记录.mp3',
                          date: '2024-01-15 14:30',
                          duration: '25分钟',
                          status: TranscriptionStatus.inProgress,
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildDropdownButton(String title, List<FilterOption> options,
      Function(List<FilterOption>) onFilterChanged) {
    return FilterOverlayDropdown(
      title: title,
      options: options,
      isMultiSelect: false,
      activeColor: Colors.blue,
      onFilterChanged: onFilterChanged,
    );
  }
}
